package model

import "github.com/crack007/go-im/pb"

func GetNodeInfo(nodeModel *NodeModel) *pb.NodeInfo {
	nodeInfo := &pb.NodeInfo{}
	nodeInfo.Id = nodeModel.Id
	nodeInfo.Ip = nodeModel.Ip
	nodeInfo.Port = uint32(nodeModel.Port)
	nodeInfo.WsPort = uint32(nodeModel.WsPort)
	nodeInfo.IsMaster = nodeModel.IsMaster
	return nodeInfo
}

func GetWorkModel(nodeInfo *pb.NodeInfo) *NodeModel {
	nodeModel := NewNodeModel()
	nodeModel.Id = nodeInfo.Id
	nodeModel.Ip = nodeInfo.Ip
	nodeModel.Port = uint16(nodeInfo.Port)
	nodeModel.WsPort = uint16(nodeInfo.WsPort)
	nodeModel.IsMaster = nodeInfo.IsMaster
	return nodeModel
}

func GetSentinelInfo(sentinelModel *SentinelModel) *pb.SentinelInfo {
	sentinelInfo := &pb.SentinelInfo{}
	sentinelInfo.Id = sentinelModel.Id
	sentinelInfo.Ip = sentinelModel.Ip
	sentinelInfo.Port = uint32(sentinelModel.Port)
	return sentinelInfo
}

func GetSentinelModel(sentinelInfo *pb.SentinelInfo) *SentinelModel {
	sentinelModel := NewSentinelModel()
	sentinelModel.Id = sentinelInfo.Id
	sentinelModel.Ip = sentinelInfo.Ip
	sentinelModel.Port = uint16(sentinelInfo.Port)
	sentinelModel.Epoch = sentinelInfo.Epoch
	return sentinelModel
}
